package cn.lg.soar.system.biz.modules.general.mapper;

import cn.lg.soar.system.biz.modules.general.entity.Template;
import cn.lg.soar.system.api.model.TemplateCache;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 模板
 * @author luguoxiang
 * @since 2025-03-03
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
public interface TemplateMapper extends BaseMapper<Template> {

    @Select("SELECT a.`type`, a.`code`, a.`name`, a.remark, a.`status` " +
            "FROM lg_sys_template a " +
            "INNER JOIN lg_sys_template_group b ON a.group_id=b.id " +
            "WHERE b.`code`=#{groupCode} " +
            "ORDER BY a.sort")
    List<Template> listByGroup(@Param("groupCode") String groupCode);

    @Select("SELECT a.`name`, a.remark, a.`type`, a.content, a.`status` " +
            "FROM lg_sys_template a " +
            "WHERE a.`code`=#{code}")
    TemplateCache getById(@Param("id") Long id);

    @Select("SELECT a.`name`, a.remark, a.`type`, a.content, a.`status` " +
            "FROM lg_sys_template a " +
            "WHERE a.`code`=#{code}")
    TemplateCache getByCode(@Param("code") String code);

}
